import { MidwayConfig } from '@midwayjs/core';
import { User } from '../entity/user';
import { Article } from '../entity/article';
import { Role } from '../entity/role';
import { Type } from '../entity/type';

export default {
  // use for cookie sign key, should change to your own and keep security
  keys: '1661220816207_6569',
  koa: {
    port: 7006,
    globalPrefix: '/api',
  },
  typeorm: {
    dataSource: {
      default: {
        /**
         * 单数据库实例
         */
        type: 'mysql',
        // host: '',
        host: '217.194.133.218',
        port: 3306,
        username: 'root',
        password: 'Simin168a',
        database: 'douban',
        synchronize: true, // 如果第一次使用，不存在表，有同步的需求可以写 true
        logging: false,
        // 配置实体模型
        entities: [User, Article, Role, Type],
        timezone: '+08:00',
      },
    },
  },
  jwt: {
    secret: 'wj-douban', // fs.readFileSync('xxxxx.key')
    expiresIn: '2d', // https://github.com/vercel/ms
  },
  cors: {
    credentials: false,
    origin: '*',
  },
  security: {
    csrf: {
      enable: false,
      type: 'ctoken',
      useSession: false,
      cookieName: 'csrfToken',
      sessionName: 'csrfToken',
      headerName: 'x-csrf-token',
      bodyName: '_csrf',
      queryName: '_csrf',
      refererWhiteList: [],
    },
    xframe: {
      enable: true,
      value: 'SAMEORIGIN',
    },
    csp: {
      enable: false,
    },
    hsts: {
      enable: false,
      maxAge: 365 * 24 * 3600,
      includeSubdomains: false,
    },
    noopen: {
      enable: false,
    },
    nosniff: {
      enable: false,
    },
    xssProtection: {
      enable: true,
      value: '1; mode=block',
    },
  },
} as MidwayConfig;
